package com.example.administrator.day35_encryptiondemo1608;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Base64;
import android.util.Log;

public class Base64Activity extends AppCompatActivity {

    private String data="望长城内外惟余莽莽";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_base64);

        //编码
        byte[] encode = Base64.encode(data.getBytes(), Base64.DEFAULT);

        Log.d("1608", "onCreate: 使用Base64编码的内容"+new String(encode));

        //
        String str="5p2t5bee5qyi6L+O5L2g";
        byte[] decode = Base64.decode(str.getBytes(), Base64.DEFAULT);
        Log.d("1608", "onCreate: 使用Base64解码的数据是"+new String(decode));
    }
}
